Ext.onReady( function() {
	Ext.QuickTips.init();
	//Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
	Ext.BLANK_IMAGE_URL = 'js/ext-2.2.1/resources/images/default/s.gif';

    var head = new Ext.Panel({
        border: false,
        layout:'anchor',
        region:'north',
        height:60,
        items: [{
            xtype:'box',
            el:'header',
            border:false,
            anchor: 'none -25'
        }, new Ext.Toolbar({
            cls:'top-toolbar',
            margins: '0 0 0 5',
            items:[ ' ',
			new Ext.form.TextField({
				width: 124,
				emptyText:'查找任意单元'
			}), ' ', ' ', new Ext.Toolbar.SplitButton({
	           	icon: 'images/find-house.gif',
                iconCls: 'x-btn-text-icon',
				tooltip: '查找任意单元',
				text: '查找',
				handler: function() {},
				menu: {items: [{
					text: '高级查询',
					icon: 'images/find-house.gif',
					iconCls: 'x-btn-text-icon',
					handler: function() {}
				}, '-', {
					text: '查询单位',
					icon: 'images/find-house.gif',
					iconCls: 'x-btn-text-icon',
					handler: function() {}
				}, {
					text: '查询地名',
					icon: 'images/find-house.gif',
					iconCls: 'x-btn-text-icon',
					handler: function() {}
				}]}
			}), '-', {
                iconCls: 'icon-collapse-all',
                tooltip: 'Collapse All',
                handler: function(){ api.root.collapse(true); }
            }, '->', {
                tooltip:'Hide Inherited Members',
                iconCls: 'icon-hide-inherited',
                enableToggle: true,
                toggleHandler : function(b, pressed){
                     mainPanel[pressed ? 'addClass' : 'removeClass']('hide-inherited');
                }
            }, '-', {
                tooltip:'Expand All Members',
                iconCls: 'icon-expand-members',
                enableToggle: true,
                toggleHandler : function(b, pressed){
                    mainPanel[pressed ? 'addClass' : 'removeClass']('full-details');
                }
            }]
        })]
    });
    
    var left = new Ext.Panel({
    	cls: 'left-tree',
    	margins: '0 0 5 5',
    	region: 'west',
    	width: 250,
    	split: true,
    	collapseMode: 'mini',
		border: true,
        layout:'border',
		id: 'treeview',
		title: '房屋视图',
		collapsible: true,
		el: 'tree',
		items: [new Ext.Toolbar({
			region: 'north',
			el: 'tree-toolbar',
			border: false,
			items: [
			'-', {
		    	id: 'importFolder',
		    	tooltip: {text: '导入数据'},
		        icon: 'images/import_folder.png',
		        iconCls: 'x-btn-text-icon'
		    }, {
		    	id: 'exportFolder',
		    	tooltip: {text: '导出数据'},
		        icon: 'images/export_folder.png',
		        iconCls: 'x-btn-text-icon'
		    }, '-', new Ext.Toolbar.Button({
		        text: '操作',
		        menu: {items: [{
			    	text: '拷贝',
			        icon: 'images/copy_folder.gif',
			        iconCls: 'x-btn-text-icon'
			    }, {
			    	text: '剪切',
			        icon: 'images/cut_folder.png',
			        iconCls: 'x-btn-text-icon'
			    }, {
			    	text: '粘贴',
			        icon: 'images/paste_folder.gif',
			        iconCls: 'x-btn-text-icon'
			    }, '-', {
			    	text: '删除',
			        icon: 'images/delete_folder.gif',
			        iconCls: 'x-btn-text-icon'
			    }]}
		    }), {
		    	tooltip: {text: '刷新视图'},
		        icon: 'images/refresh_folder.png',
		        iconCls: 'x-btn-text-icon'
		    }, '->', '-', {
		    	id: 'toggleTree',
		    	tooltip: {text: '全部展开'},
		        iconCls: 'icon-expand-tree',
		        enableToggle: true,
                toggleHandler : function(b, pressed){
		    		this.tooltip = pressed ? '全部收缩' : '全部展开';
               	 	this.iconCls = pressed ? 'icon-collapse-tree' : 'icon-expand-tree';
                }
		    }
		]}), {
            region: 'center',
            el:'treeview',
            layout: 'fit',
            border: false
        }, {
        	region: 'south',
        	el: 'propview',
        	layout: 'fit',
        	height: 200,
        	split: true,
        	border: false
        }]
    });
    
    var viewport = new Ext.Viewport({
		layout: 'border',
		items: [head, {
			region: 'center',
			layout: 'border',
			border: true,
			margins: '0 5 5 0',
			id: 'content',
			el: 'content',
			items: [new Ext.Toolbar({
				region: 'north',
				el: 'content-toolbar',
				border: false,
				items: [
				'-', {
			    	id: 'importFolder',
			    	tooltip: {text: '导入数据'},
			        icon: 'images/import_folder.png',
			        iconCls: 'x-btn-text-icon'
			    }, {
			    	id: 'exportFolder',
			    	tooltip: {text: '导出数据'},
			        icon: 'images/export_folder.png',
			        iconCls: 'x-btn-text-icon'
			    }, '-', {
			    	tooltip: {text: '刷新视图'},
			        icon: 'images/refresh_folder.png',
			        iconCls: 'x-btn-text-icon'
			    }, '->', '-', {
			    	id: 'collapseTree',
			    	tooltip: {text: '收缩'},
			        icon: 'images/collapse_tree.gif',
			        iconCls: 'x-btn-text-icon'
			    }, {
			    	id: 'expandTree',
			    	tooltip: {text: '展开'},
			        icon: 'images/expand_tree.gif',
			        iconCls: 'x-btn-text-icon'
			    }
			]})]
		}, left, {
			id: 'contentFrame',
            region: 'center',
            contentEl: 'content-iframe',
            layout: 'fit',
            border: false
        }, new Ext.Toolbar({
			region: 'south',
			el: 'foot',
			border: false,
			items: ['-', '<div id="statusbar"></div>', 
			    '->', '-', '<span style="padding-right:50px">当前登录人：吴润德</span>',
			    '-', '<span style="padding-right:50px">当前时间：2009-06-01 18:00:24</span>'
			]
		})]
	});
    viewport.doLayout();
    document.getElementById('content-iframe').src = 'canvas.jsp';
});